package com.moon.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.moon.entity.Admin;
import com.moon.dao.AdminMapper;

import java.util.List;

@Transactional
@Service
public class AdminService {
	@Autowired
	private AdminMapper adminMapper;

	public AdminMapper getAdminMapper() {
		return adminMapper;
	}

    public Admin selectByAccountAndPassword(String account, String password) {
		Admin crt = new Admin();
		crt.setAccount(account);
		crt.setPassword(password);
		return adminMapper.selectOne(crt);
	}

    public void update(Admin admin1) {
		adminMapper.updateByPrimaryKeySelective(admin1);//有选择的更新数据  没有改变的字段数据库不会改变 updateByPrimaryKey全部覆盖成新数据
    }

    public List<Admin> selectAll() {
		return adminMapper.selectAll();
    }

    public Admin selectById(Integer id) {
		return adminMapper.selectByPrimaryKey(id);
    }
}